package String;

public class _459_RepeatedSubstringPattern {
    public boolean repeatedSubstringPattern(String s) {
        int sLength = s.length();
        if (sLength == 1) {
            return false;
        }
        for (int i = 1; i <= Math.sqrt(sLength); i++) {
            StringBuffer tempsb = new StringBuffer();
            StringBuffer tempsb1 = new StringBuffer();
            if (sLength % i == 0) {
                int times = sLength / i;
                int times1 = i;
                String subS = s.substring(0, times1);
                String subS1 = s.substring(0, times);
                for (int j = 0; j < times; j++) {
                    tempsb.append(subS);
                }
                for (int j = 0; j < times1; j++) {
                    tempsb1.append(subS1);
                }
                if (tempsb.toString().equals(s)) {
                    return true;
                }
                if (times1!=1 && tempsb1.toString().equals(s)) {
                    return true;
                }
            }

        }
        return false;
    }
}
